<template>
  <button type="text" @click="open">修改</button>
</template>

<script>
export default {
  props:['index'],
  methods: {
    data(){
      return {
        fruit : ''
      }
    },
    open() {
      this.$prompt("请输入水果名称", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then(({ value }) => {
          this.$message({
            type: "success",
            message: "已修改为:" + value,
          });
          this.fruit = value;
          this.$emit('put',{'index':this.index,'fruit':this.fruit});
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入",
          });
        });
        
    },
  },
};
</script>